home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
mint
/
mint96sb.zoo
/
doc
/
filesys.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-10-15
|
15KB
|
476 lines
/*
* NOTE: This file only works if sizeof(int) == 2!
* UNLESS: you have an ANSI compiler and use prototypes
*
* Copyright 1991,1992 Eric R. Smith. This file may be re-distributed
* as long as this notice remains intact.
*/
#ifndef _filesys_h
#define _filesys_h
#ifndef P_
# ifdef __STDC__
# define P_(x) x
# else
# define P_(x) ()
# endif
#endif
#ifdef _SHORTINT
#define _wORD int
#endif
#ifndef _wORD
#ifdef __MSHORT__ /* 16 bit integers? */
#define _wORD int
#else
#define _wORD short
#endif
#endif
#define NAME_MAX 32
#define PATH_MAX 128
struct filesys; /* forward declaration */
struct devdrv; /* ditto */
typedef struct f_cookie {
struct filesys *fs; /* filesystem that knows about this cookie */
unsigned short dev; /* device info (e.g. Rwabs device number) */
unsigned short aux; /* extra data that the file system may want */
long index; /* this+dev uniquely identifies a file */
} fcookie;
/* structure for opendir/readdir/closedir */
typedef struct dirstruct {
fcookie fc; /* cookie for this directory */
unsigned short index; /* index of the current entry */
unsigned short flags; /* flags (e.g. tos or not) */
#define TOS_SEARCH 0x01
char fsstuff[60]; /* anything else the file system wants */
/* NOTE: this must be at least 45 bytes */
} DIR;
/* structure for getxattr */
typedef struct xattr {
unsigned short mode;
/* file types */
#define S_IFMT 0170000 /* mask to select file type */
#define S_IFCHR 0020000 /* BIOS special file */
#define S_IFDIR 0040000 /* directory file */
#define S_IFREG 0100000 /* regular file */
#define S_IFIFO 0120000 /* FIFO */
#define S_IMEM 0140000 /* memory region or process */
#define S_IFLNK 0160000 /* symbolic link */
/* special bits: setuid, setgid, sticky bit */
#define S_ISUID 04000
#define S_ISGID 02000
#define S_ISVTX 01000
/* file access modes for user, group, and other*/
#define S_IRUSR 0400
#define S_IWUSR 0200
#define S_IXUSR 0100
#define S_IRGRP 0040
#define S_IWGRP 0020
#define S_IXGRP 0010
#define S_IROTH 0004
#define S_IWOTH 0002
#define S_IXOTH 0001
#define DEFAULT_DIRMODE (0777)
#define DEFAULT_MODE (0666)
long index;
unsigned short dev;
unsigned short reserved1;
unsigned short nlink;
unsigned short uid;
unsigned short gid;
long size;
long blksize, nblocks;
short mtime, mdate;
short atime, adate;
short ctime, cdate;
short attr;
short reserved2;
long reserved3[2];
} XATTR;
typedef struct fileptr {
short links; /* number of copies of this descriptor */
unsigned short flags; /* file open mode and other file flags */
long pos; /* position in file */
long devinfo; /* device driver specific info */
fcookie fc; /* file system cookie for this file */
struct devdrv *dev; /* device driver that knows how to deal with this */
struct fileptr *next; /* link to next fileptr for this file */
} FILEPTR;
/* lock structure */
struct flock {
short l_type; /* type of lock */
#define F_RDLCK O_RDONLY
#define F_WRLCK O_WRONLY
#define F_UNLCK 3
short l_whence; /* SEEK_SET, SEEK_CUR, SEEK_END */
long l_start; /* start of locked region */
long l_len; /* length of locked region */
short l_pid; /* pid of locking process
(F_GETLK only) */
};
/* LOCK structure used by the kernel internally */
typedef struct ilock {
struct flock l;
struct ilock *next;
long reserved[4];
} LOCK;
typedef struct devdrv {
long (*open) P_((FILEPTR *f));
long (*write) P_((FILEPTR *f, char *buf, long bytes));
long (*read) P_((FILEPTR *f, char *buf, long bytes));
long (*lseek) P_((FILEPTR *f, long where, _wORD whence));
long (*ioctl) P_((FILEPTR *f, _wORD mode, void *buf));
long (*datime) P_((FILEPTR *f, _wORD *timeptr, _wORD rwflag));
long (*close) P_((FILEPTR *f, _wORD pid));
long (*select) P_((FILEPTR *f, long proc, _wORD mode));
void (*unselect) P_((FILEPTR *f, long proc, _wORD mode));
long reserved[3]; /* reserved for future use */
} DEVDRV;
typedef struct filesys {
struct filesys *next; /* link to next file system on chain */
long fsflags;
#define FS_KNOPARSE 0x01 /* kernel shouldn't do parsing */
#define FS_CASESENSITIVE 0x02 /* file names are case sensitive */
#define FS_NOXBIT 0x04 /* if a file can be read, it can be executed */
long (*root) P_((_wORD drv, fcookie *fc));
long (*lookup) P_((fcookie *dir, char *name, fcookie *fc));
long (*creat) P_((fcookie *dir, char *name, unsigned _wORD mode,
_wORD attrib, fcookie *fc));
DEVDRV *(*getdev) P_((fcookie *fc, long *devspecial));
long (*getxattr) P_((fcookie *fc, XATTR *xattr));
long (*chattr) P_((fcookie *fc, _wORD attr));
long (*chown) P_((fcookie *fc, _wORD uid, _wORD gid));
long (*chmode) P_((fcookie *fc, unsigned _wORD mode));
long (*mkdir) P_((fcookie *dir, char *name, unsigned _wORD mode));
long (*rmdir) P_((fcookie *dir, char *name));
long (*remove) P_((fcookie *dir, char *name));
long (*getname) P_((fcookie *relto, fcookie *dir, char *pathname));
long (*rename) P_((fcookie *olddir, char *oldname,
fcookie *newdir, char *newname));
long (*opendir) P_((DIR *dirh, _wORD tosflag));
long (*readdir) P_((DIR *dirh, char *nm, _wORD nmlen, fcookie *fc));
long (*rewinddir) P_((DIR *dirh));
long (*closedir) P_((DIR *dirh));
long (*pathconf) P_((fcookie *dir, _wORD which));
long (*dfree) P_((fcookie *dir, long *buf));
long (*writelabel) P_((fcookie *dir, char *name));
long (*readlabel) P_((fcookie *dir, char *name, _wORD namelen));
long (*symlink) P_((fcookie *dir, char *name, char *to));
long (*readlink) P_((fcookie *dir, char *buf, _wORD len));
long (*hardlink) P_((fcookie *fromdir, char *fromname,
fcookie *todir, char *toname));
long (*fscntl) P_((fcookie *dir, char *name, _wORD cmd, long arg));
long (*dskchng) P_((_wORD drv));
long zero;
} FILESYS;
/*
* this is the structure passed to loaded file systems to tell them
* about the kernel
*/
typedef long (*_LongFunc)();
struct kerinfo {
short maj_version; /* kernel version number */
short min_version; /* minor kernel version number */
unsigned short default_mode; /* default file access mode */
short reserved1; /* room for expansion */
/* OS functions */
_LongFunc *bios_tab; /* pointer to the BIOS entry points */
_LongFunc *dos_tab; /* pointer to the GEMDOS entry points */
/* media change vector */
void (*drvchng) P_((short));
/* Debugging stuff */
void (*trace) P_((char *, ...));
void (*debug) P_((char *, ...));
void (*alert) P_((char *, ...));
void (*fatal) P_((char *, ...));
/* memory allocation functions */
void * (*kmalloc) P_((long));
void (*kfree) P_((void *));
void * (*umalloc) P_((long));
void (*ufree) P_((void *));
/* utility functions for string manipulation */
short (*strnicmp) P_((char *, char *, _wORD));
short (*stricmp) P_((char *, char *));
char * (*strlwr) P_((char *));
char * (*strupr) P_((char *));
short (*sprintf) P_((char *, char *, ...));
/* utility functions for manipulating time */
void (*millis_time) P_((unsigned long, _wORD *));
long (*unixtim) P_((unsigned _wORD, unsigned _wORD));
long (*dostim) P_((long));
/* utility functions for dealing with pauses */
void (*nap) P_((unsigned short));
void (*sleep) P_((_wORD que, long cond));
void (*wake) P_((_wORD que, long cond));
void (*wakeselect) P_((long param));
/* file system utility functions */
short (*denyshare) P_((FILEPTR *, FILEPTR *));
LOCK * (*denylock) P_((LOCK *, LOCK *));
/* reserved for future use */
long res2[9];
};
/* flags for open() modes */
#define O_RWMODE 0x03 /* isolates file read/write mode */
# define O_RDONLY 0x00
# define O_WRONLY 0x01
# define O_RDWR 0x02
# define O_EXEC 0x03 /* execute file; used by kernel only */
#define O_APPEND 0x08 /* all writes go to end of file */
#define O_SHMODE 0x70 /* isolates file sharing mode */
# define O_COMPAT 0x00 /* compatibility mode */
# define O_DENYRW 0x10 /* deny both read and write access */
# define O_DENYW 0x20 /* deny write access to others */